*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      dofile_manuscript_final.do                      *;
*       Date:           25/09/2024                                      *;
*       Authors:        Baccini & Weymouth                              *;
*       Purpose:        Replication of "Inflation, Blame Attribution,   *;
*       and the 2022 US Congressional Elections"                        *;
*       Input Files:    dataset_survey_final.dta         				*; 
*       Output Files:   bjps_replication.log                            *;
*       Machine:        Office                                          *;
*       Program: 		Stata 15                                        *;
*     ****************************************************************  *;
*     ****************************************************************  *;

clear
clear matrix
clear mata

cd "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication"
use dataset_survey_final, clear
*log using bjps_replication_main.log

### Manuscript

* Figure 1 
reghdfe dem education employment gender income ID q_10 q_3 q_4 q_7 rent comm inflation_personal inflation_community, absorb(id_county) cluster(id_county)
coefplot, drop(_cons education employment gender income ID q_10 q_3 q_4 q_7 ) xline(0)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\Figure1.gph", replace

* Table 1
*1 
reg dem spending corp, r
outreg2 using table1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label
test spending = corp
*2 
reg approve_dem spending corp, r
outreg2 using table1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*3 
reg approve_re spending corp, r
outreg2 using table1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*4 
reg rep_better spending corp, r
outreg2 using table1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp


### Appendix B

* Figure B1
reghdfe dem education employment gender income ID q_10 q_3 q_4 q_7 inflation_personal inflation_community, absorb(id_county) cluster(id_county)
coefplot, drop(_cons education employment gender income ID q_10 q_3 q_4 q_7 ) xline(0) 
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\FigureB1_new.gph", replace

* Table B1
*1
reghdfe dem inflation_personal inflation_community education employment gender income i.ID q_10 q_3 q_4 q_7, absorb(id_county) cluster(id_county)
outreg2 using tableB1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') addtext(County fixed effects, Yes) label
*2 
reghdfe dem rent comm inflation_personal inflation_community education employment gender income i.ID q_10 q_3 q_4 q_7, absorb(id_county) cluster(id_county)
outreg2 using tableB1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') addtext(County fixed effects, Yes) label append

* Table B2
*1
reg inflation_personal i.ID education employment gender income q_10 q_3 q_4 q_7 i.id_county if ID<4, r cluster(id_county)
outreg2 using tableB2.xls, bdec(3) tdec(3) keep(i.ID education employment gender income q_10 q_3 q_4 q_7) addstat(`e(r2_p)') addtext(County fixed effects, Yes) label
*2
reg inflation_community i.ID education employment gender income q_10 q_3 q_4 q_7 i.id_county if ID<4, r cluster(id_county)
outreg2 using tableB2.xls, bdec(3) tdec(3) keep(i.ID education employment gender income q_10 q_3 q_4 q_7) addstat(`e(r2_p)') addtext(County fixed effects, Yes) label append

* Table B3
*1
reghdfe dem rent comm inflation_personal inflation_community education employment gender income q_10 q_3 q_4 q_7 if ID==1, absorb(id_county) cluster(id_county)
outreg2 using tableB3.xls, bdec(3) tdec(3) addstat(`e(r2_p)') addtext(County fixed effects, Yes) label
*2
reghdfe dem rent comm inflation_personal inflation_community education employment gender income q_10 q_3 q_4 q_7 if ID==2, absorb(id_county) cluster(id_county)
outreg2 using tableB3.xls, bdec(3) tdec(3) addstat(`e(r2_p)') addtext(County fixed effects, Yes) label append
*3
reghdfe dem rent comm inflation_personal inflation_community education employment gender income q_10 q_3 q_4 q_7 if ID==3, absorb(id_county) cluster(id_county)
outreg2 using tableB3.xls, bdec(3) tdec(3) addstat(`e(r2_p)') addtext(County fixed effects, Yes) label append


### Appendix C

* Figure C1
ciplot spending_cause_inflation, by(spending) level(90)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\FigureC1.gph", replace

* Figure C2
ciplot corp_cause_inflation, by(corp) level(90)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\FigureC2.gph", replace

* Figure C3
ciplot spending_cause_inflation if ID==1, by(spending) level(90)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\manipulation_spendingRE.gph", replace
ciplot spending_cause_inflation if ID==2, by(spending) level(90)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\manipulation_spendingDE.gph", replace
ciplot spending_cause_inflation if ID==2, by(spending) level(90)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\manipulation_spendingIND.gph", replace
cd "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication"
graph combine manipulation_spendingRE.gph manipulation_spendingDE.gph manipulation_spendingIND.gph, row(1)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\FigureC3.gph", replace

* Figure C4
ciplot corp_cause_inflation if ID==1, by(corp) level(90)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\manipulation_corpRE.gph", replace
ciplot corp_cause_inflation if ID==2, by(corp) level(90)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\manipulation_corpDE.gph", replace
ciplot corp_cause_inflation if ID==3, by(corp) level(90)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\manipulation_corpIND.gph", replace
cd "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication"
graph combine manipulation_corpRE.gph manipulation_corpDE.gph manipulation_corpIND.gph, row(1)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\Baccini Weymouth Inflation\survey\survey_new\0 Replication\FigureC4.gph", replace

* Table C1
*1
reg dem spending corp if ID==1, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label
test spending = corp
*2
reg dem spending corp if ID==2, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*3
reg dem spending corp if ID==3, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*4
reg approve_dem spending corp if ID==1, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*5
reg approve_dem spending corp if ID==2, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*6
reg approve_dem spending corp if ID==3, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*7 
reg approve_re spending corp if ID==1, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*8
reg approve_re spending corp if ID==2, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*9
reg approve_re spending corp if ID==3, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*7 
reg rep_better spending corp if ID==1, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*8
reg rep_better spending corp if ID==2, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp
*9
reg rep_better spending corp if ID==3, r
outreg2 using tableC1.xls, bdec(3) tdec(3) addstat(`e(r2_p)') label append
test spending = corp

log close
